home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5035 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  52 lines

  1. Path: ix.netcom.com!netnews
  2. From: froman@ix.netcom.com(James Edward Sands III )
  3. Newsgroups: comp.lang.c++
  4. Subject: NEWBIE:strings, spacing, white_spacing
  5. Date: 2 Feb 1996 06:29:03 GMT
  6. Organization: Netcom
  7. Message-ID: <4esavf$sqb@cloner4.netcom.com>
  8. References: <3111CD7E.2A81@dg.com>
  9. NNTP-Posting-Host: ix-den8-12.ix.netcom.com
  10. X-NETCOM-Date: Thu Feb 01 10:29:04 PM PST 1996
  11.  
  12.  
  13.  
  14. Ok,
  15.     I am reading a string (actually many) heres a sample,
  16.  
  17. #include<iostream.h>
  18. #include<stdio.h>
  19. #include<cstring.h>
  20. static int skip_whitespace(int sk = 0) ;
  21.  
  22. main()
  23. {
  24. string xchar;
  25. xchar.skip_whitespace(0) ;
  26. cout << "Input :" << endl;
  27. cin >> xchar;
  28. cout << "Output :" << xchar << endl;
  29.  
  30. return 0;
  31. }
  32.  
  33. The purpose in the real program is to read addresses (the ones on
  34. letters), and I want to read the address lines in one by one.
  35.  
  36. When a string is inputed such as      12651 West Alabama Apt 203
  37. I only receive, as output,            12651
  38. and somehow the rest is put into the remaining cin statements
  39. variables.  The spacing in the input seems critical to the placement of
  40. the rest of the data.  Help screens, and books, talk little about
  41. letting a space stay in a string field, though they do mention
  42. something about whitespacing.  I do not want to use fixed length
  43. fields, such as         char x[10]
  44. The length of the string must be dynamic, meaning changing to 
  45. conform to the inputed length.
  46. I am using Borland 4.5
  47.  
  48.                                 thanks,
  49.  
  50.                                 Jim
  51.  
  52.